<page-header [autoTitle]="false"></page-header>
<nz-card>
  <section class="search-section">
    <input nz-input placeholder="活动标题" [(ngModel)]="keyword" class="search-item"/>
    <button nz-button [nzType]="'primary'" nzGhost (click)="search()" class="search-item">
      <i class="anticon anticon-search"></i><span>搜索</span>
    </button>
    <button nz-button [nzType]="'primary'" (click)="addEntity()"  class="search-add-right">
      <i class="anticon anticon-plus"></i><span>添加</span>
    </button>
  </section>
  <nz-table #nzTable [nzData]="page.content"
            [nzPageSize]="page.size"
            [nzTotal]="page.totalElements"
            [nzFrontPagination]="false"
            [(nzPageIndex)]="page.number"
            (nzPageIndexChange)="changePageNo($event)"
            [nzLoading]="isLoading">
    <thead>
    <tr>
      <th nz-th><span>序号</span></th>
      <th nz-th><span>活动标题</span></th>
      <th nz-th><span>活动按钮名称</span></th>
      <th nz-th><span>活动说明</span></th>
      <th nz-th><span>是否固定数量</span></th>
      <th nz-th><span>是否活动中</span></th>
      <th nz-th><span>操作</span></th>
    </tr>
    </thead>
    <tbody>
    <tr *ngFor="let data of nzTable.data;let i=index">
      <td>
        {{i+1}}
      </td>
      <td>{{data.title}}</td>
      <td>{{data.btnText}}</td>
      <td>{{data.remark|stringEllipsisCutPipe:16}}</td>
      <td>{{data.fixedQuantity|yesNoPipe}}</td>
      <td>{{data.inActivity|yesNoPipe}}</td>
      <td>
        <a href="javascript:void (0);" routerLink="/company/list/detail" [queryParams]="{id: data.id}">查看详情</a>
        <span *ngIf="data.inActivity == 2">
             <nz-divider nzType="vertical"></nz-divider>
            <nz-popconfirm [nzTitle]="'确定上线活动该活动动吗？'" (nzOnConfirm)="setInActivity(data)">
              <a nz-popconfirm>上线活动</a>
            </nz-popconfirm>
        </span>
        <span *ngIf="data.inActivity == 1">
             <nz-divider nzType="vertical"></nz-divider>
            <nz-popconfirm [nzTitle]="(data.topNum?'下线活动将影响小程序首页排版，':'')+'确定下线该活动动吗？'" (nzOnConfirm)="setUnActivity(data)">
              <a nz-popconfirm>下线活动</a>
            </nz-popconfirm>
        </span>
      </td>
    </tr>
    </tbody>
  </nz-table>
</nz-card>
